package com.zt.csp.shorturl.controller;

import com.zt.csp.shorturl.constents.RedisKey;
import com.zt.csp.shorturl.dto.ServiceResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 缓存相关操作
 * Created by zt on 2018/4/17 0017
 */
@RestController
@RequestMapping("/cache")
public class CacheController {
    @Autowired
    private RedisTemplate<String, String> redisTemplate;


    @PostMapping("/clean_all")
    public ServiceResult cleanAllCache() {
        // 删除短链接防重复缓存
        redisTemplate.delete(RedisKey.LONG_SHORT_HASH);
        // 访问计数不应该被删除
        // Dew.cluster.cache.del(RedisKey.SHORT_COUNT);
        return ServiceResult.ok(null);
    }

}
